//
//  DoctorApplyController.m
//  QuickCure37
//
//  Created by 马文星 on 16/6/18.
//  Copyright © 2016年 Demos. All rights reserved.
//

#import "DoctorApplyController.h"
#import "DoctorApplyDTO.h"
#import "DoctorApplyCell.h"
#import "DoctorApplyInfoController.h"

@interface DoctorApplyController () <UITableViewDataSource,UITableViewDelegate>


@property (nonatomic, strong) UITableView *tableview;

/** dto 数组 */
@property (nonatomic, strong) NSMutableArray *dtoArray;

@end

@implementation DoctorApplyController

static NSString  *ID = @"CityID";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    [self loadData];
    
}

- (void)setupUI{
    
    self.title = @"申请名医通";
    
    /*!
     *  添加控件
     */
    [self.view addSubview:self.tableview];
//    [self.tableview registerClass:[DoctorApplyCell class] forCellReuseIdentifier:ID];
    
    /*!
     *  添加约束
     */
    
    [self.tableview mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(0);
        make.left.right.bottom.mas_equalTo(0);
        
    }];
}

- (void)loadData{
    
    //全是假数据
    DoctorApplyDTO *dto1 = [DoctorApplyDTO doctorApplyDTOWithName:@"张先生" caseString:@"高血压" cureTimeString:@"就诊:2016/06/19" doctor:@"马医生" doctor_calss:@"主任医生" hospitol:@"上海长征医院" cureState:@"审核中"];
    
    DoctorApplyDTO *dto2 = [DoctorApplyDTO doctorApplyDTOWithName:@"李先生" caseString:@"心血管" cureTimeString:@"就诊:2016/06/19" doctor:@"马医生" doctor_calss:@"主任医生" hospitol:@"上海长征医院" cureState:@"审核中"];
    
    DoctorApplyDTO *dto3 = [DoctorApplyDTO doctorApplyDTOWithName:@"王先生" caseString:@"骨科病" cureTimeString:@"就诊:2016/06/19" doctor:@"马医生" doctor_calss:@"主任医生" hospitol:@"上海长征医院" cureState:@"已就诊"];
    
    DoctorApplyDTO *dto4 = [DoctorApplyDTO doctorApplyDTOWithName:@"赵先生" caseString:@"心塞梗塞" cureTimeString:@"就诊:2016/06/19" doctor:@"马医生" doctor_calss:@"主任医生" hospitol:@"上海长征医院" cureState:@"已就诊"];
    
    DoctorApplyDTO *dto5 = [DoctorApplyDTO doctorApplyDTOWithName:@"马先生" caseString:@"关节炎" cureTimeString:@"就诊:2016/06/19" doctor:@"马医生" doctor_calss:@"主任医生" hospitol:@"上海长征医院" cureState:@"审核中"];
    
    DoctorApplyDTO *dto6 = [DoctorApplyDTO doctorApplyDTOWithName:@"过先生" caseString:@"腰肌劳损" cureTimeString:@"就诊时间:2016/06/19" doctor:@"马医生" doctor_calss:@"主任医生" hospitol:@"上海长征医院" cureState:@"已就诊"];

    [self.dtoArray addObject:dto1];
    [self.dtoArray addObject:dto2];
    [self.dtoArray addObject:dto3];
    [self.dtoArray addObject:dto4];
    [self.dtoArray addObject:dto5];
    [self.dtoArray addObject:dto6];
    
}


#pragma mark  - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dtoArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DoctorApplyCell *cell = (DoctorApplyCell *)[tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        
        cell = [[DoctorApplyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    cell.dto = self.dtoArray[indexPath.row];
    
    return cell;
}


#pragma mark  - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    DoctorApplyInfoController *infoVC = [[DoctorApplyInfoController alloc] init];
 
    infoVC.dto = self.dtoArray[indexPath.row];
 
    [self.navigationController pushViewController:infoVC animated:YES];
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}


#pragma mark  - Lazy
-(UITableView *)tableview{
    
    if (_tableview == nil) {
        _tableview = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableview.dataSource = self;
        _tableview.delegate = self;
        _tableview.rowHeight = 90;
        _tableview.tableFooterView = [UIView new];
    }
    return _tableview;
    
}

-(NSMutableArray *)dtoArray{

    if (_dtoArray == nil) {
        _dtoArray = [[NSMutableArray alloc] init];
    }
    return _dtoArray;
}



@end
